
" Tag Formatter Function /*{{{*/
" Author: David Fishburn
"
function! Format_SGML() range
	" Add a new line to the bottom of the mark to be removed later
	call cursor(a:lastline,1)
	put =''
	silent! exec "ma z"
	" Add a new line above the mark to be removed later
	call cursor(a:firstline,1)
	put! = ''
	silent! exec "ma y"

	" Put each tag on a newline
	exec line("'y").','.line("'z").'s/>\s*</>\r</ge'
	" Reformat using Vim's indenter
	call cursor(line("'y"),1)
	exec 'normal! '.(line("'z")-line("'y")+1).'=='

	" Delete the additional lines added
	silent! exe "norm! 'ydd'zdd"
endfunction
command! -range=% -nargs=0 FormatSGML <line1>,<line2>call Format_SGML()
" /*}}}*/
